package com.zhu.shop.goods.controller;

import com.zhu.shop.common.Vo.goods.GoodsVo;
import com.zhu.shop.common.Vo.Result;
import com.zhu.shop.goods.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/goods")
public class GoodsController {
    @Autowired
    private GoodsService goodsService;
    @GetMapping("/findGoods/{id}")
    public Result<GoodsVo> findGoodsById(@PathVariable("id")Long id){
        try {
            //模拟网络拥挤
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("调用了商品微服务22222222");
        return goodsService.findGoodsById(id);
    }

    @GetMapping("/test")
    public Result<String> test(){
        return Result.success("模拟高并发");
    }
}
